/*
 *  Copyright 2009 Utkin Dmitry
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
 
/* 
 *  This file is part of the WSF Staff project.
 *  Please, visit http://code.google.com/p/staff for more information.
 */

// This file generated by staff_codegen
// DO NOT EDIT

#ifndef _SERVICEFACTORY_H_
#define _SERVICEFACTORY_H_

#include <typeinfo>
#include <string>
#include <staff/security/Security.h>

//! service factory
class CServiceFactory
{
public:
  //!         get instance of service factory
  static CServiceFactory& Inst();

  //!         allocate new object for work with service
  /*! example:
      CCalculator* pCalculator = CServiceFactory::Inst().GetService<CCalculator>("http://localhost:9090/axis2/services/Calculator")

      \param  sServiceUri - service URI
      \param  sSessionId - session identifier
      \return pointer to object for work with service
      */
  template<typename TServiceClientBaseType>
  TServiceClientBaseType* GetService( const std::string& sServiceUri = "",
                                      const std::string& sSessionId = STAFF_SECURITY_GUEST_SESSION_ID )
  {
    return reinterpret_cast<TServiceClientBaseType*>(AllocateClient(typeid(TServiceClientBaseType).name(), sServiceUri, sSessionId));
  }

private:
  //! private constructor
  CServiceFactory();

  void* AllocateClient(const std::string& sClientType, const std::string& sServiceUri, const std::string& sSessionId);

private:
  static CServiceFactory* m_pInst;  //!< instance
};

#endif // _SERVICEFACTORY_H_
